﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="/static/js/common.js"></script>
    <style>
        .el-dialog__body {
            height: 100% !important;
        }

            .el-dialog__body iframe {
                height: 90% !important;
            }

        .el-dialog.is-fullscreen {
            overflow: hidden !important;
        }

        .el-dialog__wrapper {
            position: absolute !important;
        }

        .el-dialog {
            width: 100% !important;
            height: 100% !important;
            margin: 0 !important;
        }
    </style>
</head>

<body>

    <div id="app" v-cloak>

        <el-form label-position="right" ref="form" :inline="true" :model="formInline" class="demo-form-inline"
                 style="margin-bottom: 15px;">
            <el-row>
                <el-col class="head-tool">
                    <div class="new_title fl">
                        <strong><img src="/static/images/icon1.png" />角色管理列表</strong>
                    </div>
                    <span>
                        <btn :text="col.btnSelect" imgsrc="/static/images/search.png" linetype="3" @click="onSubmit">
                        </btn>
                        <btn :text="col.btnAdd" linetype="3" v-if="authorize('RoleController_SaveAsync')"
                             @click="UserInput('tj')"></btn>
                        <btn text="功能管理" imgsrc="/static/images/general.png" linetype="3"
                             v-if="authorize('RoleController_UpdateRoleMenu')" @click="MenuManage"></btn>
                        <btn :text="col.btnDelete" linetype="4" v-if="authorize('RoleController_DeleteMutiAsync')"
                             @click="onDelete"></btn>
                    </span>
                </el-col>
            </el-row>
            <el-row>
                <!--工厂组件-->
                <list-factorys-all v-model="formInline.model.CreateFactory"></list-factorys-all>
                <el-col :xs="6" :sm="6" :md="6" :lg="4" :xl="4">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input v-model="formInline.model.name" placeholder="角色名称" size="mini">
                                <template slot="prepend">
                                    角色名称
                                </template>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
            </el-row>
        </el-form>

        <el-table stripe ref="table" highlight-current-row @current-change="tableHandleCurrentChange"
                  :data="ListItem.tableData" :row-key="getRowKeys" :height="ListItem.tableHeight" border
                  @selection-change="handleSelectionChange" row-style="height:10px" style="width: 100%;">
            <el-table-column type="selection" style="
    padding-top: 0px;
    padding-bottom: 0px;
" align="center" width="55" :reserve-selection="true">
            </el-table-column>
            <el-table-column prop="name" label="角色名称" min-width="110">
            </el-table-column>
            <el-table-column prop="code" label="角色编码" min-width="100">
            </el-table-column>
            <el-table-column prop="createFactoryText" label="工厂" min-width="150">
            </el-table-column>
            <el-table-column prop="remarks" label="备注" min-width="150">
            </el-table-column>
            <el-table-column width="53" v-if="authorize('RoleController_SaveAsync')" prop="update"
                             :label="col.btnUpdate" fixed="right">
                <template slot-scope="scope">
                    <button type="button" class="elst-bt-xg" @click=UserInput('xg',scope.row.id)>
                        <i class="el-icon-edit"></i>
                    </button>
                </template>
            </el-table-column>

        </el-table>

        <el-row type="flex" justify="end">
            <el-pagination ref="page" @size-change="handleSizeChange" @current-change="handleCurrentChange"
                           :current-page="ListItem.currentPage" :page-sizes="ListItem.pagesizes" :page-size="ListItem.pagesize"
                           :layout="ListItem.layout" :total="ListItem.total">
            </el-pagination>
        </el-row>

        <el-dialog title="角色信息" :visible.sync="ListItem.dialogVisible" @close='closeDialog' width="80%" height="80%"
                   top="10vh">
            <iframe ref="iframe" :src="ListItem.InputUrl" style="height:95%;width:100%" frameborder="0"></iframe>
        </el-dialog>
        <el-dialog :title="'正在为角色：'+currSeelctRow.name+' 配置功能'" fullscreen="true" :visible.sync="SysRoleMenuIsShow"
                   @close='closeDialog' width="80%" height="80%" top="10vh">
            <iframe ref="iframe" :src="SysRoleMenuUrl" style="height:95%;width:100%" frameborder="0"></iframe>
        </el-dialog>
    </div>
    <script type="text/javascript">
        var app = new Vue({
            el: '#app',
            data: {
                pageInitial: {},
                //表单内容
                ListItem: ListItem,
                SysRoleMenuUrl: "",
                SysRoleMenuIsShow: false,
                currSeelctId: "",
                currSeelctRow: {
                    name: ""
                },
                formInline: {
                    model: {
                        "code": "",
                        "name": "",
                        "remarks": "",
                        "createFactory": ""
                    },
                    offset: 0,
                    limit: 10
                }
            },
            mounted: function () {
                //列表高度自适应
                tablehigh(this);
                this.pageInitial = PageInitial([], [
                    "RoleController_GetList",
                    "RoleController_SaveAsync",
                    "RoleController_DeleteMutiAsync",
                    "RoleController_Get",
                    "RoleController_UpdateRoleMenu"
                ]);
                this.$nextTick(function () {
                    //初始化数据
                    this.GetPageData(1);
                });
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                authorize: function (functionCode) { return authorize(this.pageInitial.authorizeList, functionCode); },
                //关闭Dialog 回调
                closeDialog: function () { },
                //删除方法
                onDelete: function () { onDelete(this, '/api/Role/DeleteMuti'); },
                //列表选择触发
                handleSelectionChange: function (val) { handleSelectionChange(this, val); },
                //Dialog展示
                UserInput: function (val, id) { DialogShow(this, val, "SysRoleInput.html", id); },
                //获取分页数据
                GetPageData: function (currentIndex) { GetPageData(this, currentIndex, '/api/Role/GetList') },
                //查询方法
                onSubmit: function () { onSubmit(this); },
                //pagesize改变 触发方法
                handleSizeChange: function (val) { handleSizeChange(this, val); },
                //跳页触发方法
                handleCurrentChange: function (val) { handleCurrentChange(this, val); },
                //table选中行handle
                tableHandleCurrentChange: function (currentRow) {
                    this.currSeelctId = currentRow.id;
                    this.currSeelctRow = currentRow;

                    //console.log(' this.currSeelctId', this.currSeelctId)
                    //console.log(' this.currSeelctRow', this.currSeelctRow)
                },
                //功能管理Dialog相关
                //功能管理Dialog展示
                MenuManage: function () {


                    //console.log('length', this.ListItem.tableMultipleSelection.length)
                    //console.log('tableMultipleSelection', this.ListItem.tableMultipleSelection)
                    //if (this.ListItem.tableMultipleSelection.length == 0) {
                    //    showMessage("选择一条数据进行操作", "error")
                    //    return;
                    //}
                    //this.currSeelctRow.name = this.ListItem.tableMultipleSelection[0].name;
                    //this.SysRoleMenuUrl = "SysRoleMenu.html?id=" + this.ListItem.tableMultipleSelection[0].id + "&t=" + Date.parse(new Date());
                    //this.SysRoleMenuIsShow = true;
                    if (!this.currSeelctId) {
                        showMessage("选择一条数据进行操作", "error")
                        return;
                    }
                    this.SysRoleMenuUrl = "SysRoleMenu.html?id=" + this.currSeelctId + "&t=" + Date.parse(new Date());
                    //console.log(' this.SysRoleMenuUrl', this.SysRoleMenuUrl)
                    this.SysRoleMenuIsShow = true;
                },
                //功能管理Dlog关闭回调
                MenuManagecloseDialog: function () { this.SysRoleMenuIsShow = false; },
            }
        });
    </script>
</body>

</html>